<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="acanto" uri="http://freegas.googlecode.com/acanto-tabs-taglib" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ include file="../commons/common.jsp" %>

<h1>Secure Page</h1>
<p>
This is a protected page. You can get to me if you've been remembered,
or if you've authenticated this session.
</p>

<c:set var="formFilter" value="${sessionScope.anagraficaFilter}" />

<table class="body-table" cellpadding="0" cellspacing="0">	
	<tr>
		<td class="title">MenuItem</td>
	</tr>
	<tr>
		<td class="functions">
		<ul>		
			<li onclick="frm.newItem('new.jsp');">Nuovo</li>				
			<li onclick="frm.deleteItems('list.jsp');">Elimina</li>
			<li onclick="frm.refresh();">Aggiorna</li>	
		</ul>
		</td>
	</tr>
	
	<tr>
		<td class="detail">
			<input type="text" name="filterValue" value="${formFilter.filterValue}">&nbsp;
			<select name="filterName">
				<option value=""> -- </option>
				<option value="menuItem.id">Id</option>
			</select>
			&nbsp;

			<input type="image" src="${searchIcon}" style="vertical-align:bottom;" alt="Cerca" onclick="frm.simpleFilter();" />
			<input type="image" src="${cancelIcon}" style="vertical-align:bottom;" alt="Cancella filtro" onclick="frm.resetFilter();" />		
		</td>
	</tr>
</table>

<acanto:dataset id="listaMenuItemDs" stateful="true"
	query="from MenuItem menuItem"
	orderBy="menuItem.position" resultsPerPage="20">

	<acanto:datasetFilter>
		<c:if test="${not empty formFilter.filterName}">
		</c:if>
			<acanto:filterCondition	fieldName="${formFilter.filterName}"
				value="${formFilter.filterValue}" operator="startsWith" />
	</acanto:datasetFilter>
	
</acanto:dataset>	

<acanto:datatable dataset="${listaMenuItemDs}" htmlClass="data" cellpadding="1" cellspacing="1" 
				defaultAscImg="${ascIcon}" defaultDescImg="${descIcon}"
				rendered="${listaMenuItemDs.availableRows > 0}">
	<tr>
		<th style="text-align:left; width: 20px;">N.</th>
		<acanto:header orderBy="menuItem.position" style="width: 40px;">Position</acanto:header>
		<acanto:header orderBy="menuItem.id" style="width: 40px;">ID</acanto:header>
		<acanto:header orderBy="menuItem.parent" style="width: 40px;">Parent</acanto:header>
	</tr>
	<acanto:row style="cursor:pointer;">
		<td style="text-align:left;">${absoluteRowNumber}.</td>
		
		<td onclick="frm.edit('update.jsp','position=${row.position}');">
			${row.position}				
		</td>
		<td onclick="frm.edit('update.jsp','id=${row.id}');">
			${row.id}				
		</td>
		<td onclick="frm.edit('update.jsp','parent=${row.parent}');">
			${row.parent}				
		</td>
	</acanto:row>
</acanto:datatable>

<c:set var="ds" scope="request" value="${listaMenuItemDs}" />

<%@ include file="../commons/paging.jsp" %>

<sec:authorize access="hasRole('ROLE_SUPERVISOR')">
    You are a supervisor! You can therefore see the <a href="ultrasecure.htm">extremely secure page</a>.<br/><br/>
</sec:authorize>

<h3>Properties obtained using &lt;sec:authentication /&gt; tag</h3>
<table border="1">
<tr><th>Tag</th><th>Value</th></tr>
<tr>
<td>&lt;sec:authentication property='name' /&gt;</td><td><sec:authentication property="name"/></td>
</tr>

<tr>
<td>&lt;sec:authentication property='principal.username' /&gt;</td><td><sec:authentication property="principal.username"/></td>
</tr>

<tr>
<td>&lt;sec:authentication property='principal.enabled' /&gt;</td><td><sec:authentication property="principal.enabled"/></td>
</tr>

<tr>
<td>&lt;sec:authentication property='principal.accountNonLocked' /&gt;</td><td><sec:authentication property="principal.accountNonLocked"/></td>
</tr>

<tr>
<td>&lt;sec:authentication property='principal.groups' /&gt;</td><td><sec:authentication property="principal.groups"/></td>
</tr>

</table>

